/**
 * 
 */
package com.wubo.sec.web.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.wubo.common.web.BaseAction;
import com.wubo.sec.SecurityManager;
import com.wubo.sec.config.SecurityConstant;
import com.wubo.sec.core.UserData;

/**
 * 
 * @author WuBo
 * @CreateDate 2012-2-16
 */
public class BaseSecAction extends BaseAction {
	protected int start;
	protected int limit = 10;
	protected long total;
	
	protected boolean flag = false;

	public boolean isFlag() {
		return flag;
	}

	public void setFlag(boolean flag) {
		this.flag = flag;
	}
	
	protected void setUserAttributesToRequest(){
		HttpServletRequest request = ServletActionContext.getRequest();
		UserData user = (UserData) SecurityManager.getCurrentUser();
		if(user != null){
			request.setAttribute(SecurityConstant.USER, user);
			request.setAttribute(SecurityConstant.ISADMIN, SecurityManager.isAdmin());
			request.setAttribute(SecurityConstant.ISMARKLOCKED, SecurityManager.isMarkLocked());
			request.setAttribute(SecurityConstant.PRIORITY, SecurityManager.getPriorityOfCurrentUser());
		}
	}
	
	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public long getTotal() {
		return total;
	}

	public void setTotal(long total) {
		this.total = total;
	}
	
}
